import axios from 'axios'

//axios请求基本配置
const baseURL = 'http://127.0.0.1:8080'

export function request(config){
    const instance = axios.create({
        baseURL,
        timeout: 5000
    })

    //请求拦截器
    instance.interceptors.request.use(config => {
        return config
    },error => {
        console.log(error)
    })

    //响应拦截器
    instance.interceptors.response.use(res => {
        //直接返回响应数据
        return res.data
    },err => {
        console.log(err)
    })

    return instance(config)
}